/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.epam.expertsys.web;

import java.io.IOException;
import java.sql.SQLException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;

/**
 *
 * @author Admin
 */
public class LogoutServlet extends AbstractServletCommand {

    private static Logger log = Logger.getLogger(LogoutServlet.class);

    @Override
    public void process(HttpServletRequest req, HttpServletResponse resp)
            throws SQLException, ServletException, IOException {

        String login = (String) req.getSession().getAttribute("login");

        req.getSession().removeAttribute("login");
        req.getSession().removeAttribute("authorized");

        log.info("User " + login + " logged out");

        RequestDispatcher reqDisp = req.getRequestDispatcher("/login.jsp");
        reqDisp.forward(req, resp);

    }
}
